<template>
  <div>
    <el-row>
      <el-col :span="24">
        <div class="addccc">
          <el-button
            type="primary"
            @click="newest(1)"
            icon="el-icon-circle-plus-outline"
            >新建</el-button
          >
        </div>
      </el-col>
      <el-col :span="24">
        <el-table :data="tableData" style="width: 100%">
          <el-table-column type="expand">
            <template #default="props">
              <el-form label-position="left" inline class="demo-table-expand">
                <el-form-item label="联系人:">
                  <span>{{ props.row.name1 }}</span>
                </el-form-item>
                <el-form-item label="采购计划:">
                  <span>{{ props.row.shop }}</span>
                </el-form-item>
                <el-form-item label="交货周期:">
                  <span>{{ props.row.id }}</span>
                </el-form-item>
                <el-form-item label="经费来源:">
                  <span>{{ props.row.shopId }}</span>
                </el-form-item>
                <el-form-item label="预计签订时间:">
                  <span>{{ props.row.category }}</span>
                </el-form-item>
                <el-form-item label="报备日期:">
                  <span>{{ props.row.address }}</span>
                </el-form-item>
                <el-form-item label="其他信息:">
                  <span>{{ props.row.desc }}</span>
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>
          <el-table-column label="最终用户" prop="name"> </el-table-column>
          <el-table-column label="应用场合" prop="desc"> </el-table-column>
          <el-table-column label="产品型号" prop="desc1"> </el-table-column>
          <el-table-column label="报价(元)" prop="desc2"> </el-table-column>
          <el-table-column label="采购数量" prop="desc3"> </el-table-column>
          <el-table-column label="销售人员" prop="desc4"> </el-table-column>

          <el-table-column label="审批">
            <template #default="scope">
              <el-tag type="success" v-if="scope.row.desc5 == 0">已通过</el-tag>
              <el-tag type="warning" v-if="scope.row.desc5 == 1">审批中</el-tag>
              <el-tag type="danger" v-if="scope.row.desc5 == 2">已驳回</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="240" align="center">
            <template #default="scope">
              <el-button
                size="mini"
                @click="handleEdit(scope.$index, scope.row)"
                >审核</el-button
              >
              <el-button
                size="mini"
                type="danger"
                @click="handleDelete(scope.$index, scope.row)"
                >下载</el-button
              >
              <el-button
                size="mini"
                type="danger"
                @click="handleDelete(scope.$index, scope.row)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <el-dialog
      :title="single"
      v-model="plassets"
      width="45%"
      :close-on-click-modal="false"
    >
      <el-form ref="form" :inline="true" :model="form" label-width="100px">
        <el-form-item label="最终用户">
          <el-input v-model="form.newuser" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="联系人">
          <el-input v-model="form.contact" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="应用场合">
          <el-select
            style="width: 300px"
            v-model="form.customer"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="item in occasion"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品型号">
          <el-select
            style="width: 300px"
            v-model="form.gridModel"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="item in foreach"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="数量">
          <el-input
            type="number"
            v-model="form.offset"
            style="width: 300px"
          ></el-input>
        </el-form-item>
        <el-form-item label="报价(元)">
          <el-input v-model="form.counter" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="采购计划">
          <el-input
            type="textarea"
            :rows="2"
            style="width: 300px"
            placeholder="请输入内容"
            v-model="form.procurement"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="经费来源">
          <el-input v-model="form.funding" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="预定签署日期">
          <el-date-picker
            style="width: 300px"
            v-model="form.dates"
            type="date"
            placeholder="选择日期"
            format="YYYY 年 MM 月 DD 日"
          >
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="报价单上传">
          <el-upload
            action="https://jsonplaceholder.typicode.com/posts/"
            list-type="picture-card"
            :on-preview="handlePictureCardPreview"
            :on-remove="handleRemove"
          >
            <i class="el-icon-plus"></i>
          </el-upload>
          <el-dialog v-model="dialogVisible">
            <img width="100%" :src="dialogImageUrl" alt="" />
          </el-dialog>
        </el-form-item>
        <el-form-item label="其他信息">
          <el-input
            type="textarea"
            :rows="2"
            style="width: 300px"
            placeholder="请输入内容"
            v-model="form.another"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="plassets = false">取 消</el-button>
          <el-button type="primary" v-if="under == 1" @click="determine()"
            >确 定</el-button
          >
          <el-button @click="hardware()" v-else type="primary"
            >编辑 确 定</el-button
          >
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      plassets: false,
      under: 1,
      single: "销售报备单",
      dialogImageUrl: "",
      dialogVisible: false,
      form: {
        newuser: "",
        contact: "",
        customer: "",
        gridModel: "",
        offset: "",
        counter: "",
        procurement: "",
        funding: "",
        dates: "",
        another: "",
      },
      occasion: [], //应用场合
      foreach: [], //产品型号
      tableData: [
        {
          name1: "张三",
          name: "中船重工海声科技有限公司",
          category: "xxxxxx",
          desc: "钢材焊缝残余应力检测",
          desc1: "USG",
          desc2: "10000",
          desc3: "1",
          desc4: "xxxxx",
          desc5: "0",
          address: "xxxx",
          shop: "xxxxx",
          shopId: "xxxxxx",
        },
      ],
    };
  },
  methods: {
    newest(index) {
      this.under = index;
      this.single = "销售报备单";
      this.plassets = true;
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
  },
};
</script>

<style >
.addccc {
  margin-bottom: 20px;
  margin-left: 20px;
}
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 100px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>